﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

using NGE;

namespace NGE.ToNImage
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string[] fns;

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();
            fd.RestoreDirectory = true;
            fd.Multiselect = true;
            fd.Filter = "*.png|*.png";
            if (fd.ShowDialog() == DialogResult.OK)
            {
                fns = fd.FileNames;

                richTextBox1.Clear();
                foreach (string fn in fns)
                {
                    richTextBox1.AppendText(fn + "\n");
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (fns == null)
            {
                return;
            }

            foreach (string fn in fns)
            {
                FileIndexer fi = new FileIndexer(fn);
                NImage nimg = new NImage();
                nimg.GetData(fn);
                Util.SaveObject(fi.PathName + fi.FileName + ".nimg", nimg);
            }
        }
    }
}
